//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.carhailing.system.controller;

import com.carhailing.common.domain.DriverUser;
import com.carhailing.common.requst.DriverUserReq;
import com.carhailing.common.response.JwtResponse;
import com.carhailing.common.result.Result;
import com.carhailing.system.service.DriverUserService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"system"})
public class DriverUserController {
    @Autowired
    private DriverUserService driverUserService;

    public DriverUserController() {
    }

    @GetMapping({"/sendCode/{phone}"})
    public Result sendCode(@PathVariable("phone") String phone) {
        return this.driverUserService.sendCode(phone);
    }

    @PostMapping({"/login"})
    public Result<JwtResponse> login(@RequestBody DriverUserReq userReq) {
        return this.driverUserService.login(userReq);
    }

    @GetMapping({"/getDriverInfo"})
    public Result<DriverUser> getDriverInfo() {
        DriverUser driverUser = this.driverUserService.DriverUserInfo();
        return Result.success(driverUser);
    }

    @GetMapping({"/getDriverList"})
    public Result<List<DriverUser>> getDriverList() {
        List<DriverUser> list = this.driverUserService.list();
        return Result.success(list);
    }

    @PostMapping({"/AddDriverUser"})
    public Result AddDriverUser(@RequestBody DriverUser driverUser) {
        return Result.success(this.driverUserService.save(driverUser));
    }
}
